/**
 * 本地全局字典
 */
import {
    SYS_DIC
} from './sys_dic'
const DIC = {
    ...SYS_DIC,
    STATE: [{
        label: '有效',
        value: 1,
        color: 'green'
    }, {
        label: '无效',
        value: 0,
        color: 'red'
    }],
    YesNo: [{
        label: '是',
        value: 1,
        color: 'green'
    }, {
        label: '否',
        value: 0,
        color: 'red'
    }],
    RefundFlag: [{
        label: '已返款',
        value: 1,
        color: 'green'
    }, {
        label: '未返款',
        value: 0,
        color: 'red'
    }]
}

function getLabelFromDic(dicKey, key) {
    if (typeof dicKey === 'string') {
        dicKey = DIC[dicKey];
    }
    const results = dicKey.filter(el => el.value === key);
    if (results && results.length) {
        return results[0].label;
    }
    return ''
}

export {
    getLabelFromDic,
    DIC
}
